package bg.uni_sofia.conf_manager.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.eclipse.persistence.oxm.annotations.XmlInverseReference;

@Entity
@NamedQueries({
	@NamedQuery(name = "getAllLectures",
			query = "SELECT l FROM Lecture l"),
	@NamedQuery(name = "getLecturesByLecturer",
			query = "SELECT l FROM Lecture l WHERE l.lecturer.id = :id"),
	@NamedQuery(name = "getLecturesByConference",
			query = "SELECT l FROM Lecture l WHERE l.conference.id = :id"),
	@NamedQuery(name = "getLecturesByStatus",
	query = "SELECT l FROM Lecture l WHERE l.status = :status"),
	@NamedQuery(name = "getLectureByTitle",
	query = "SELECT l FROM Lecture l WHERE l.title = :title"),
})
	

@XmlRootElement
public class Lecture implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -6965292482523861613L;
	@Id @GeneratedValue(strategy = GenerationType.AUTO) 
	private long id; 
	private String title;
	private String description;
	@ManyToOne
	private Conference conference;
	private int length;
	@Temporal(TemporalType.DATE)
	private Date createDate;
	@Temporal(TemporalType.DATE)
	private Date date;
	private String time;
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastModified;
	private int status; 
	@ManyToOne
	private Lecturer lecturer;
		
	public Lecture(){
		
	}

	public String getTime() {
		return time;
	}


	public void setTime(String time) {
		this.time = time;
	}
	public Lecture(String title, String description, Conference conference,
			int length, Date createDate, Date date, String time,
			Date lastModified, int status, Lecturer lecturer) {
		super();
		this.title = title;
		this.description = description;
		this.conference = conference;
		this.length = length;
		this.createDate = createDate;
		this.date = date;
		this.time = time;
		this.lastModified = lastModified;
		this.status = status;
		this.lecturer = lecturer;
	}

	public long getId() {
		return id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	//@XmlTransient
	public Lecturer getLecturer() {
		return lecturer;
	}

	public void setLecturer(Lecturer lecturer) {
		this.lecturer = lecturer;
	}

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public Date getLastModified() {
		return lastModified;
	}

	public void setLastModified(Date lastModified) {
		this.lastModified = lastModified;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}
	@XmlTransient
	public Conference getConference() {
		return conference;
	}

	public void setConference(Conference conference) {
		this.conference = conference;
	}
	
	@Override
	public String toString() {
		
		return "Lecture is " + title+" "+description+" "+length;
	}
}


